package net.yla.smartbus.module.controller.web.ba.right.right;

import net.yla.smartbus.core.api.ApiResult;
import net.yla.smartbus.core.base.BaseController;
import net.yla.smartbus.module.ba.right.right.form.RightsForm;
import net.yla.smartbus.module.ba.right.right.query.QueryOfActual;
import net.yla.smartbus.module.ba.right.right.service.RightsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Date: 2020-08-24 10:45
 * @Author: Being Nobody
 * @Version: 1.0
 */
@RestController
@RequestMapping("/api/web/rights")
public class RightController extends BaseController {

    @Autowired
    private RightsService rightsService;

    /**
     * 1 查询指定角色的有效权限
     *
     * @param query
     * @return
     */
    @PostMapping("/actual")
    public ApiResult actual(@RequestBody @Validated QueryOfActual query) {
        return success(rightsService.actual(query));
    }


    /**
     * 2 查询指定角色的权限列表
     *
     * @param query
     * @return
     */
    @PostMapping("/list")
    public ApiResult list(@RequestBody @Validated QueryOfActual query) {
        return success(rightsService.list(query));
    }

    /**
     * 3 保存指定角色的权限信息
     *
     * @param form
     * @return
     */
    @PostMapping("/save")
    public ApiResult save(@RequestBody @Validated RightsForm form) {
        return success(rightsService.save(form));
    }

}
